Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Parse in reverse. AST goes in, code comes out.
import { print } from 'esrap';
const { code, map } = print({
type: 'Program',
body: [
{
type: 'ExpressionStatement',
expression: {
callee: {
type: 'Identifier',
name: 'alert'
},
arguments: [
{
type: 'Literal',
value: 'hello world!'
}
]
}
}
]
});
console.log(code); // alert('hello world!');
If the nodes of the input AST have loc
properties (e.g. the AST was generated with acorn
with the locations
option set), sourcemap mappings will be created.
You can pass the following options:
const { code, map } = print(ast, {
// Populate the `sources` field of the resulting sourcemap
// (note that the AST is assumed to come from a single file)
sourceMapSource: 'input.js',
// Populate the `sourcesContent` field of the resulting sourcemap
sourceMapContent: fs.readFileSync('input.js', 'utf-8'),
// Whether to encode the `mappings` field of the resulting sourcemap
// as a VLQ string, rather than an unencoded array. Defaults to `true`
sourceMapEncodeMappings: false,
// String to use for indentation — defaults to '\t'
indent: ' ',
// Whether to wrap strings in single or double quotes — defaults to 'single'.
// This only applies to string literals with no `raw` value, which generally
// means the AST node was generated programmatically, rather than parsed
// from an original source
quotes: 'single'
});
esrap
can also print TypeScript nodes, assuming they match the ESTree-like @typescript-eslint/types
.
Because it's ginormous.
This repo uses pnpm. Once it's installed, do pnpm install
to install dependencies, and pnpm test
to run the tests.
1.4.3
\r
FAQs
Parse in reverse
The npm package esrap receives a total of 369,349 weekly downloads. As such, esrap popularity was classified as popular.
We found that esrap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.